#include<bits/stdc++.h>
using namespace std;
#define N 10010
int n,m,c,fa[N],sum;
struct node
{
    int a,b,w;
}Node,edge[N];
bool cmp(struct node a,struct node b)
{
    return a.w < b.w;
}
int Find(int x)
{
    while(x != fa[x])
    {
        x = fa[x];
    }
    return x;
}
int main()
{
    while(cin >> c >> n >> m)
    {
        sum = 0;
        for(int i = 0; i <= m; i ++)
        {
            fa[i] = i;
        }
        for(int i = 0; i < n;i ++)
        {
            cin >> edge[i].a >> edge[i].b >> edge[i].w;
        }
        sort(edge,edge+n,cmp);
        for(int i = 0;i < n;i ++){
            int x = Find(edge[i].a);
            int y = Find(edge[i].b);
            if(x != y){
                fa[x] = y;
                sum += edge[i].w;
            }
        }
        if(sum <= c){
            cout << "Yes" << endl;
        }else{
            cout<< "No" <<endl;

        }
    }
    return 0;
}
Graph[][]

